package com.xianzhiOA.util;

import org.springframework.web.servlet.ModelAndView;

/**
 * Created by Administrator on 2017/4/20.
 */
public class PageUtil {

    //分页工具类
    public static void fen(int length, int page,int pages,ModelAndView mv){
        int pBegin;
        int pEnd;

        if(pages>length){
            pBegin = page-length/2;
            if(pBegin<=0){
                pBegin = 1;
            }
            pEnd = length+pBegin-1;
            if(pEnd>pages){
                pEnd = pages;
                pBegin = pEnd -length+1;
            }
        }else{
            pBegin = 1;
            pEnd =pages;
        }

       /* System.out.println(length+"===="+pBegin+"===="+pEnd);*/

        mv.addObject("pBegin",pBegin);
        mv.addObject("pEnd",pEnd);

    }
}
